<div class="fsh-rightPanel">
    <div class="layui-anim layui-anim-upbit">
        <div id="list_form" lay-filter="aljdfklj" class="layui-form layui-form-item wx-search" >
            <div class="layui-inline" style="padding-top: 5px">
                <select name="plan_classify_id" id="plan_classify_id">
                </select>
            </div>
            <div class="layui-inline" style="padding-top: 5px">
                <input id="_squadName2" type="text" name="schoolName" lay-verify="required" readonly placeholder="请选择班级" class="layui-input">
                <input id="_squadCode2" type="hidden" name="principalCode" lay-verify="required" readonly class="layui-input">
            </div>
            <button class="layui-btn btn-primary" id="search">搜索</button>
        </div>
        <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
    </div>
</div>
<script>
    layui.use(['layer', 'table'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var tableObj = table.render({//展示已知数据
            elem: '#list_table'
            , url: context + '/api/eduCoursePlan/listForSchool'
            , request: {
                limitName: 'pageSize'
            }
            , even: true
            , page: true //是否显示分页
            , limits: [10, 20, 30]
            , limit: 10 //每页默认显示的数量
            , cols: [[ //标题栏
                {field: 'id', title: 'ID', sort: true, align: 'center', width: 100}
                ,{field: 'title', title: '计划名称', align: 'center'}
                ,{field: 'title', title: '属于分类', align: 'center', templet: function (d) {
                        return plan_classify[d.plan_classify_id]||'';
                    }}
                , {field: 'createDate', title: '授权时间', align: 'center'}
                , {
                    field: 'lock', title: '操作', width: 260, align: 'center', unresize: true,
                    templet: function (d) {
                        return '<a href="javascript:;" class="font-primary" lay-event="find">查看</a>'
                            + '<a href="javascript:;" class="font-primary" lay-event="dispatch">授权班级</a>'
                            + '<a href="javascript:;" class="font-primary" lay-event="design">克隆</a>';
                    }
                }
            ]]
        });

        // 检索
        $("#search").click(function () {
            reloadTable(tableObj);
        });
        // 添加
        $("#plan_add").click(function () {
            showDialog({
                title: '新增计划'
                , template: 'add'
                , yes: function (index, layero) {
                    layer.close(index);
                }
            })
        });
        //表格内部操作按钮监听
        table.on('tool(mainList)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'design') {
                //showAlert("等待开发");
            } else if (layEvent === 'find') {//查看计划完整详情
                showBigDialog({
                title: '查看详情 - ' + data.title
                    , template: 'detail'
                    , htmlData: data
            });
            } else if (layEvent === 'dispatch') {//授权
                showBigDialog({
                    title: '授权班级 - ' + data.title
                    , template: 'authPlan'
                    , htmlData: data
                })
            }
        });

        //初始化分类下拉菜单
        intPlanClassify();

        //选择班级
        selectSquad('_squadName2','_squadCode2');
    });
</script>
